package practices;
import java.util.Scanner;

public class NumberFormatExceptionDemo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数 ");

        try {
            int num = Integer.parseInt(sc.nextLine());
            System.out.println("输入的整数是: " + num);
        }
        catch (NumberFormatException e) {
            e.printStackTrace();
            System.out.println("输入的不是整数, 请重新输入 ");
        }finally {
            sc.close();
        }

    }
}
